<template>
	<view :style="{'height':Height+'px'}" style="background-color: #03B3FE;overflow: hidden;">
		<view class="new-list-header" style="background: url(/static/background/new-bg.png);background-size: cover;">
			<uni-nav-bar left-icon="left" color="#ffffff" @clickLeft="back"  title="余额转赠"></uni-nav-bar>
		</view>
		<form @submit="subCash" report-submit='true'>
		<view class="main">
			<view class="main-header">
				<view class="main-title">转赠</view>
				<view class="main-icon">
					<image src="/static/background/money-sl-icon.png"></image>
				</view>
			</view>
			<view class="main-list" style="border-radius: 10px 10px 0 0;">
				<view class="list-title">转赠金额</view>
				<view class="list-input">
					&yen;<input :placeholder='"最低转让数"+minPrice' placeholder-class='placeholder' name="money" type='digit'/>
				</view>
				<view class="list-tips" style="color: #AFAFAF;line-height: 40px;">
					当前可用余额：<text class="price">￥{{userInfo.now_shengyu_money}}</text>
				</view>
			</view>
			<view class="main-list" style="border-radius: 0 0 10px 10px;">
				<view class="list-title">接收信息</view>
				<view class="list-input">
					<input placeholder='接收人手机号码或者编号' placeholder-class='placeholder' name="phone" />
				</view>
				
			</view>
		</view>
		<view class="main-image">
			<image src="/static/background/money-sp-bg.png" mode="widthFix"></image>
		</view>
		<button formType="submit" class='main-button' >转让</button>
		</form>
		<!-- <view class='cash-withdrawal'>
			<view class='wrapper'>
				<view :hidden='currentTab != 0' class='list'>
					<form @submit="subCash" report-submit='true'>
						<view class='item acea-row row-between-wrapper'>
							
							<view class='name'>转增</view>

							<view class='input'><input :placeholder='"最低转让数"+minPrice' placeholder-class='placeholder' name="money" type='digit'></input></view>
						</view>
						
						<view class='item acea-row row-between-wrapper'>
							<view class='name'>接收信息</view>
							<view class='input'><input :placeholder='"接收人手机号码或者编号"' placeholder-class='placeholder' name="phone"></input></view>
						</view>
						
						<view class='tip'>
							当前可用余额: <text class="price">￥{{userInfo.now_shengyu_money}}</text>
						</view>

						<button formType="submit" class='bnt bg-color' >转让</button>
					</form>
				</view>
			</view>	
		</view> -->
		<home v-if="navigation"></home>
	</view>
</template>

<script>
	import {
		getBuyCredit2,
		getUserMoney,
		getUserStoreMoney,
		extractBank,
		getUserInfo,
		checkPayPassword
	} from '@/api/user.js';
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	import colors from '@/mixins/color';
	import home from '@/components/home';
	// #ifdef MP
	import authorize from '@/components/Authorize';
	
	// #endif

	export default {
		components: {

			// #ifdef MP
			authorize,
			// #endif
			home
		},
		mixins:[colors],
		data() {
			return {
				show_key:false,
				pwd: '',
				navList: [{
						'name': '银行卡',
						'icon': 'icon-yinhangqia'
					},
					{
						'name': '微信',
						'icon': 'icon-weixin2'
					},
					{
						'name': '支付宝',
						'icon': 'icon-icon34'
					}
				],
				examinationTypeArrayType:'-----请选择------',
				examinationTypeIndex:0,
				examinationTypeArray: ['-----请选择------','银行卡','微信','支付宝', 'USTD'],
				currentTab: 0,
				index: 0,
				array: [], //提现银行
				minPrice: 500.00, //最低提现金额
				userInfo: [],
				isClone: false,
				isAuto: false, //没有授权的不会自动授权
				isShowAuth: false, //是否隐藏授权
				qrcodeUrlW:"",
				qrcodeUrlZ:"",
				integralType:'',
				xuanzhong:'1',
				Height:500
			};
		},
		computed: mapGetters(['isLogin']),
		watch:{
			isLogin:{
				handler:function(newV,oldV){
					if(newV){
						this.getUserInfo();
						this.getUserExtractBank();
					}
				},
				deep:true
			}
		},
		onLoad(options) {
			this.integralType = options.type || 1;
			console.log(this.integralType);
			if (this.isLogin) {
				this.getUserInfo();
				// this.getUserExtractBank();
			} else {
				toLogin();
			}
			var that = this;
			uni.getSystemInfo({
				success:function(res){
					that.Height = res.windowHeight;
				}
			})
		},
		methods: {
			
			back(){
				uni.navigateBack()
			},
			radio(e){
					//console.log(e,'---')
					this.xuanzhong=e  //把传过来的值赋给点击的按钮
			  },
			examinationType(e) {
			    this.examinationTypeIndex = e.target.value;
			    this.examinationTypeArrayType=this.examinationTypeArray[this.examinationTypeIndex]
			   },
			// uploadpicW(){
			// 	this.uploadpic(this.qrcodeUrlW);
			// },
			// uploadpicZ(){
			// 	this.uploadpic(this.qrcodeUrlZ);
			// },
			/**
			 * 上传文件
			 * 
			*/
			uploadpic: function (type) {
			  let that = this;
			  that.$util.uploadImageOne('upload/image', function (res) {
				  if(type==='W'){
					  that.qrcodeUrlW = res.data.url;
				  }else{
					  that.qrcodeUrlZ = res.data.url;
				  }
			  });
			},
			/**
			 * 删除图片
			 * 
			*/
			DelPicW: function () {
			  this.qrcodeUrlW = "";
			},
			DelPicZ: function () {
			  this.qrcodeUrlZ = "";
			},
			onLoadFun: function() {
				this.getUserInfo();
				// this.getUserExtractBank();
			},
			// 授权关闭
			authColse: function(e) {
				this.isShowAuth = e
			},
			getUserExtractBank: function() {
				let that = this;
				extractBank().then(res => {
					let array = res.data.extractBank;
					array.unshift("请选择银行");
					that.$set(that, 'array', array);
					that.minPrice = 100;//res.data.minPrice;
				});
			},
			/**
			 * 获取个人用户信息
			 */
			getUserInfo: function() {
				let that = this;
				getUserInfo().then(res => {
					that.userInfo = res.data;
					that.userInfo.now_shengyu_money = that.userInfo.now_money - that.userInfo.frozen_money;
				});
			},
			swichNav: function(current) {
				this.currentTab = current;
			},
			bindPickerChange: function(e) {
				this.index = e.detail.value;
			},
			subCash: function(e) {
				let that = this,
					value = e.detail.value;



					console.log(value);
				
				if (value.phone.length == 0) return that.$util.Tips({
					title: '请输入接收人手机号码或者编号'
				});

				if (value.money.length == 0) return that.$util.Tips({
					title: '请填写转让数量'
				});
				
				if (value.money < that.minPrice) return that.$util.Tips({
					title: '转让数量不能低于' + that.minPrice
				});
				
					getBuyCredit2(value).then(res => {
						that.getUserInfo();
						return that.$util.Tips({
							title: res.msg,
							icon: 'success'
						},{url:'/pages/users/user_money/index',tab:2});
					}).catch(err => {
						return that.$util.Tips({
							title: err
						});
					});

				
			}
		}
	}
</script>

<style scoped lang="scss">
	page {
		background-color: #fff !important;
	}
	
	.main{
		 background:linear-gradient(180deg, #FFCD00 0%, #F68A42 100%);
		 width:90%;
		 margin-left:5%;
		 border-radius: 10px;
		 margin-top: 50px;
		 padding-bottom: 20px;
	}
	.main-header{
		width: 90%;
		padding: 0 5%;
		display: flex;
	}
	.main-title{
		font-family: YouSheBiaoTiHei;
		color: #FFFFFF;
		font-size: 20px;
		font-weight: bold;
		flex: 1;
		line-height: 40px;
	}
	.main-icon{
		text-align: right;
	}
	.main-icon>image{
		width: 100px;
		height: 100px;
		position: relative;
		top: -30px;
		right: -50px;
	}
	.main-list{
		clear: both;
		width: 90%;
		margin: 0 5%;
		padding: 0 5%;
		background-color: #FFFFFF;
	}
	.list-title{
		color: #333333;
		font-size: 16px;
		line-height: 40px;
	}
	.list-input{
		display: flex;
		line-height: 40px;
		font-size: 28px;
	}
	.list-input>input{
		height: 40px;
		marign-top:5px;
		line-height: 40px;
		padding-left: 20px;
	}
	.main-image>image{
		width: 100%;
	}
	.main-button{
		background: linear-gradient(180deg, #FFCD00 0%, #F68A42 100%) !important;
		color: #FFFFFF;
		border-radius: 20px;
		height: 40px;
		line-height: 40px;
		font-size: 16px;
		font-weight: blod;
		position: fixed;
		bottom: 100px;
		width: 90%;
		left: 5%;
	}
	.cash-withdrawal .nav {
		height: 130rpx;
		box-shadow: 0 10rpx 10rpx #f8f8f8;
	}
	.cash-withdrawal .header {
		
		// background-image: url("http://absh.cqmv.com/uploads/attach/2021/09/20210923/2921e8244f6e03d19a18c3ed4809ee47.png");
		background-repeat: no-repeat;
		    background-size: 100% 100%;
		    width: 100%;
		    height: 140rpx;
			line-height: 180rpx;
		    font-size: 36px;
		    color: #fff;
		    // padding: 15px 0 22px 0;
		    box-sizing: border-box;
		    text-align: center;
		    font-family: 'Guildford Pro';
		    background-color: var(--view-theme);
	}
	.cash-withdrawal .nav .item {
		font-size: 26rpx;
		flex: 1;
		text-align: center;
	}

	.cash-withdrawal .nav .item~.item {
		border-left: 1px solid #f0f0f0;
	}

	.cash-withdrawal .nav .item .iconfont {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;
		border: 2rpx solid #30cc67;
		text-align: center;
		line-height: 37rpx;
		margin: 0 auto 6rpx auto;
		font-size: 22rpx;
		box-sizing: border-box;
	}

	.cash-withdrawal .nav .item .iconfont.on {
		background-color: #30cc67;
		color: #fff;
		border-color: #30cc67;
	}

	.cash-withdrawal .nav .item .line {
		width: 2rpx;
		height: 20rpx;
		margin: 0 auto;
		transition: height 0.3s;
	}

	.cash-withdrawal .nav .item .line.on {
		height: 39rpx;
	}

	.cash-withdrawal .wrapper .list {
		padding: 0 30rpx;
	}

	.cash-withdrawal .wrapper .list .item {
		border-bottom: 1rpx solid #eee;
		min-height: 28rpx;
		font-size: 30rpx;
		color: #333;
		padding: 39rpx 0;
	}

	.cash-withdrawal .wrapper .list .item .name {
		width: 130rpx;
	}

	.cash-withdrawal .wrapper .list .item .input {
		width: 505rpx;
	}

	.cash-withdrawal .wrapper .list .item .input .placeholder {
		color: #bbb;
	}
	
	.cash-withdrawal .wrapper .list .item .picEwm,.cash-withdrawal .wrapper .list .item .pictrue{
		width:140rpx;
		height:140rpx;
		border-radius:3rpx;
		position: relative;
		margin-right: 23rpx;
	}
	
	.cash-withdrawal .wrapper .list .item .picEwm image{
		width:100%;
		height:100%;
		border-radius:3rpx;
	}
	
	.cash-withdrawal .wrapper .list .item .picEwm .icon-guanbi1{
		position:absolute;
		right: -14rpx;
		top: -16rpx;
		font-size:40rpx;
	}
	
	.cash-withdrawal .wrapper .list .item .pictrue{
		border:1px solid rgba(221,221,221,1);
		font-size:22rpx;
		color: #BBBBBB;
	}
	
	.cash-withdrawal .wrapper .list .item .pictrue .icon-icon25201{
		font-size: 47rpx;
		color: #DDDDDD;
		margin-bottom: 3px;
	}

	.cash-withdrawal .wrapper .list .tip {
		font-size: 26rpx;
		color: #999;
		margin-top: 25rpx;
	}

	.cash-withdrawal .wrapper .list .bnt {
		font-size: 32rpx;
		color: #fff;
		width: 690rpx;
		height: 90rpx;
		text-align: center;
		border-radius: 50rpx;
		line-height: 90rpx;
		margin: 64rpx auto;
	}

	.cash-withdrawal .wrapper .list .tip2 {
		font-size: 26rpx;
		color: #999;
		text-align: center;
		margin: 44rpx 0 20rpx 0;
	}

	.cash-withdrawal .wrapper .list .value {
		height: 135rpx;
		line-height: 135rpx;
		border-bottom: 1rpx solid #eee;
		width: 690rpx;
		margin: 0 auto;
	}

	.cash-withdrawal .wrapper .list .value input {
		font-size: 80rpx;
		color: #282828;
		height: 135rpx;
		text-align: center;
	}

	.cash-withdrawal .wrapper .list .value .placeholder2 {
		color: #bbb;
	}

	.price {
		color: $theme-color;
	}
</style>
